This file contains code snippets for use with the following exercises from Chapter 22:

 - Create a Word document from scratch
 - Ribbon customization
 - Binding Custom XML data to content controls

You can also find code snippets for use with exercise on adding a macro to the Ribbon from chapter 23. The Chapter 23 code is at the end of this file. Note that this file contains the XML code only and not the related VBA macro.

****************************************
When copying code, be sure to select all characters, including outside angle brackets, for the applicable code -- but do NOT select any characters beyond the code snippet (such as extra hard returns or the asterisks or underscores used here to divide the code snippets for ease of reference.)
****************************************


Create a document from scratch
________________________________________

document.xml
****************************************
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"><w:body><w:p><w:r><w:t>This is the first Word document I've created from scratch.</w:t></w:r></w:p><w:sectPr><w:pgSz w:w="12240" w:h="15840"/><w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"/><w:cols w:space="720"/><w:docGrid w:linePitch="360"/></w:sectPr></w:body></w:document>

[Content_Types].xml
****************************************
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/></Types>

.rels
****************************************
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/></Relationships>



Ribbon customization
_________________________________________

CustomUI.xml
*****************************************

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon><tabs><tab id="customTab" label="My Tab"><group id="customGroup" label="My Sample Group"><button idMso="PasteSpecialDialog" visible="true" size="large" label="Choose a Paste Option" /><gallery idMso="TableInsertGallery" visible="true" size="large" label="Add Table" /> <button idMso="FileSave" visible="true" size="large" /></group></tab></tabs></ribbon></customUI>


.rels 
(IMPOTANT: REMEMBER TO REPLACE THE # in the code below with an rID number not already in use in the file!!!)
*****************************************
<Relationship Type="http://schemas.microsoft.com/office/2006/relationships/ui/extensibility" Target="/customUI/customUI.xml" Id="rId#" />


Data Binding
_________________________________________

item1.xml
*****************************************
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><myinfo xmlns="http://www.arouet.net/AMOD/CustomXML.htm"><email>My e-mail address</email><motto>Add a favorite saying here.</motto></myinfo>

itemProps1.xml
*****************************************
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ds:datastoreItem ds:itemID="{462820BB-4D2B-41C2-812E-F3CA7850A5A9}" xmlns:ds="http://schemas.openxmlformats.org/officedocument/2006/2/customXml"><ds:schemaRefs><ds:schema Ref="http://www.arouet.net/AMOD/CustomXML.htm"/></ds:schemaRefs></ds:datastoreItem>

item1.xml.rels
*****************************************
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps" Target="itemProps1.xml"/></Relationships>


data binding code to add to document.xml for binding the first control
(IMPORTANT: If you change the GUID in the itemProps1.xml file, change it here as well)
*****************************************
<w:dataBinding w:prefixMappings="xmlns:ns0='http://www.arouet.net/AMOD/CustomXML.htm'" w:xpath="/ns0:myinfo[1]/ns0:email[1]" w:storeItemID="{462820BB-4D2B-41C2-812E-F3CA7850A5A9}" />

relationship to add to document.xml.rels
(IMPOTANT: REMEMBER TO REPLACE THE # in the code below with an rID number not already in use in the file!!!)
*****************************************
<Relationship Id="rId#" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml" Target="../customXML/item1.xml" />


Adding a macro to the Ribbon - from Chapter 23
_________________________________________

CustomUI.xml
*****************************************

<?xml version="1.0" encoding="utf-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"><ribbon><tabs><tab idMso="TabView"><group id="myGroup" label="Say Hello" insertAfterMso="GroupZoom"><button id="Sample" visible="true" size="large" label="Click Me" onAction="Sample" imageMso="QueryBuilder"/></group></tab></tabs></ribbon></customUI>


.rels 
(IMPOTANT: REMEMBER TO REPLACE THE # in the code below with an rID number not already in use in the file!!!)
*****************************************

<Relationship Type="http://schemas.microsoft.com/office/2006/relationships/ui/extensibility" Target="/customUI/customUI.xml" Id="rID#" />